<?php

/*
 * Action 5$
 *
 * +1 action
 * +2$
 * Name a card. Reveal the top card of your deck. If it's the named card, put it into your hand.
 */

class Mystic extends Card implements iAction, iKingdom, iDarkAges {

    public function __construct() {
        parent::__construct("Mystic", 5);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 action",
            "+2$",
            "Name a card. Reveal the top card of your deck. If it's the named card, put it into your hand.");
    }

    public function play(Game $game, $isRealCard) {
        $game->addActions(1);
        $game->addMoney(new Price(2));
        ScreenDisplay::addScreenMessage($game, true, "get +1 action and 2$", "gets +1 action 2$ ");

        $tempCard = $game->peekCardFromDrawDeck();
        if ($tempCard != null) {
            $board_cards = $game->getAllBoardCards();
            ksort($board_cards);
            
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $board_cards, 1, 1, null, "Wish for a card");
            $card = n2c($output[0]);
            ScreenDisplay::addScreenMessage($game, true, "wish for " . nicePrint($card), "wishes for " . ScreenDisplay::$LMSG);
            $wish_card = $game->peekCardFromDrawDeck();
            if ($wish_card->getKey() == $card->getKey()) {
                $game->drawCards(1);
                ScreenDisplay::addScreenMessage($game, false, " and you get it! ", " and he gets it!");
            } else {
                ScreenDisplay::addScreenMessage($game, false, " but reveal ".  nicePrint($wish_card). ", what a shame", " but reveals ". ScreenDisplay::$LMSG. ", what a failure");   
            }
        }
        $game->cardActionFinished();
        return true;
    }

}

?>